package com.rbac.web.model.res;

import com.rbac.web.model.Role;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author gengaoliu
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "角色列表返回参数")
public class RoleGetListRes {
  @Schema(description = "id")
  private Integer id;

  @Schema(description = "名称")
  private String name;

  @Schema(description = "编码")
  private String code;

  @Schema(description = "状态")
  private Boolean enabled;

  @Schema(description = "描述")
  private String description;

  public static RoleGetListRes fromDomain(Role role) {
    return RoleGetListRes.builder()
        .id(role.getId())
        .name(role.getName())
        .code(role.getCode())
        .enabled(role.getDisabled())
        .description(role.getDescription())
        .build();
  }
}
